﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="MRP.aspx.cs" Inherits="VSM.Business.Parts.Purchasing.MRP" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function onCalendarShown(calendarID) {
            var cal = $find("calendarFrom");
            cal._switchMode("months", true);
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", call);
                    }
                }
            }
        }

        function onCalendarHidden() {
            var cal = $find("calendarFrom");
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild, "click", call);
                    }
                }
            }
        }

        function call(eventElement) {
            var target = eventElement.target;
            switch (target.mode) {
                case "month":
                    var cal = $find("calendarFrom");
                    cal._visibleDate = target.date;
                    cal.set_selectedDate(target.date);
                    cal._switchMonth(target.date);
                    cal._blur.post(true);
                    cal.raiseDateSelectionChanged();
                    break;
            }
        }


        function onCalendarShownTo(calendarID) {
            var cal = $find("calendarTo");
            cal._switchMode("months", true);
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", callTo);
                    }
                }
            }
        }

        function onCalendarHiddenTo() {
            var cal = $find("calendarTo");
            if (cal._monthsBody) {
                for (var i = 0; i < cal._monthsBody.rows.length; i++) {
                    var row = cal._monthsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild, "click", callTo);
                    }
                }
            }
        }

        function callTo(eventElement) {
            var target = eventElement.target;
            switch (target.mode) {
                case "month":
                    var cal = $find("calendarTo");
                    cal._visibleDate = target.date;
                    cal.set_selectedDate(target.date);
                    cal._switchMonth(target.date);
                    cal._blur.post(true);
                    cal.raiseDateSelectionChanged();
                    break;
            }
        }

        function OpenDocList() {
            var url = "../../MRPPOList.aspx"
            Main.openCustomDialog(url, 800, 610);
        }

        function OpenMRPList() {
            var url = "../../MRPList.aspx"
            Main.openCustomDialog(url, 800, 610, "MRP List");
        }
        function OpenABC() {
            var url = "MRPABC.aspx"
            Main.openCustomDialog(url, 800, 610, "Parts - MRP ");
        }
    </script>
    <div>
        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:HiddenField ID="hdnIsUpdate" runat="server" />
                <asp:HiddenField ID="hdnAbsID" runat="server" />
                <h2>
                    &nbsp;MRP
                </h2>
                <div style="margin-left: 5px; width: 99%;">
                    <hr />
                    <table border="0" width="100%" style="background-color: #D1D4D8; font-weight: bold;">
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                Run Date :
                            </td>
                            <td style="width: 180px">
                                <asp:TextBox ID="txtRunDate" runat="server" Width="150px" Height="21px"></asp:TextBox>
                            </td>
                            <td align="left" style="
                                width: 300px;">
                                <asp:RadioButton ID="radSea" runat="server" Text="Sea order forecast" Checked="True"
                                    GroupName="order" OnCheckedChanged="radSea_CheckedChanged" AutoPostBack="true" />
                                <asp:RadioButton ID="radAir" runat="server" Text="Air order forecast" GroupName="order"
                                    OnCheckedChanged="radAir_CheckedChanged" AutoPostBack="true" />
                                <asp:RadioButton ID="radMO" runat="server" Checked="True" GroupName="Dealer" 
                                    Text="MO" oncheckedchanged="radMO_CheckedChanged"  AutoPostBack="true"/>
                                <asp:RadioButton ID="radEO" runat="server" GroupName="Dealer" Text="EO" 
                                    oncheckedchanged="radEO_CheckedChanged" AutoPostBack="true" />
                            </td>
                            <td>
                                <asp:DropDownList ID="dllType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dllType_SelectedIndexChanged">
                                    <asp:ListItem Selected="True"></asp:ListItem>
                                    <asp:ListItem>A</asp:ListItem>
                                    <asp:ListItem>B</asp:ListItem>
                                    <asp:ListItem>C</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td align="right">
                                <asp:Button ID="btnABC" runat="server" OnClientClick="OpenABC()" Text="ABC" Width="80px" />
                                <asp:Button ID="btnRun" runat="server" OnClick="btnRun_Click" Text="Run" Width="80px" />
                            </td>
                        </tr>
                    </table>
                    <hr />
                    <div style="width: 100%">
                        <asp:GridView ID="grvFCT1" CssClass="GridInner" runat="server" Width="100%" BorderColor="White"
                            BackColor="White" AllowSorting="True" AutoGenerateColumns="False" CellPadding="2"
                            HeaderStyle-Height="27px" CellSpacing="2" HeaderStyle-VerticalAlign="Middle"
                            AllowPaging="True" PageSize="10" OnPageIndexChanging="grvFCT1_PageIndexChanging"
                            OnRowDataBound="grvSearchResult_RowDataBound">
                            <PagerSettings Mode="NumericFirstLast" />
                            <PagerStyle BackColor="#70A0D0" Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />
                            <RowStyle BackColor="#D9E0ED" BorderColor="White" BorderWidth="2px" Height="25px" />
                            <AlternatingRowStyle BackColor="#EEF1F7" BorderColor="White" BorderWidth="2px" />
                            <Columns>
                                <asp:TemplateField HeaderText="#">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblNo" runat="server" Text='<%# Bind("No") %>' BorderStyle="none">
                                        </asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Parts No">
                                    <ItemStyle HorizontalAlign="Left" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblItemCode" runat="server" Text='<%# Bind("ItemCode") %>' BorderStyle="none"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Parts Name">
                                    <ItemStyle HorizontalAlign="left" Width="200px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblItemName" runat="server" Text='<%# Bind("ItemName") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Vendor">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblVendorCode" runat="server" Text='<%# Bind("CardCode") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Model">
                                    <ItemStyle HorizontalAlign="Center" Width="30px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblModel" runat="server" Text='<%# Bind("U_Model") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="ABC" Visible="false">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblClassType" runat="server" Text='<%# Bind("ClassType") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Class"  Visible="false">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblClassType" runat="server" Text='<%# Bind("U_Class") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="No. of items"  Visible="false">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblOnHand" runat="server" Text='<%# Bind("OnHand") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="No. of line items"  Visible="false">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblVendorName" runat="server" Text='<%# Bind("NumberLine") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Cumulated line items"  Visible="false">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblCumulated" runat="server" Text='<%# Bind("Cumulated") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Cumulated line items"  Visible="false">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblTargetFillRate" runat="server" Text='<%# Bind("TargetFillRate") %>'
                                            BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="M1">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblm1" runat="server" Text='<%# Bind("M1") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="M2">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblm2" runat="server" Text='<%# Bind("M2") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="M3">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblm3" runat="server" Text='<%# Bind("M3") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="M4">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblm4" runat="server" Text='<%# Bind("M4") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="M5">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblm5" runat="server" Text='<%# Bind("M5") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="M6">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblm6" runat="server" Text='<%# Bind("M6") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="AvgMon">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblAvgMon" runat="server" Text='<%# Bind("AvgMon") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="OC">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblOrdrIntrvl" runat="server" Text='<%# Bind("OrdrIntrvlDisplay") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="LT">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblLeadTime" runat="server" Text='<%# Bind("LeadTime") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Standard Deviation">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblLeadTime" runat="server" Text='<%# Bind("StandardDeviation") %>'
                                            BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Service Rate">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblServiceRate" runat="server" Text='<%# Bind("ServiceRate") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Leadtime Factor">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblLeadtimeFactor" runat="server" Text='<%# Bind("LeadtimeFactor") %>'
                                            BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="SS">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblSS" runat="server" Text='<%# Bind("SS") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Stock On Hand">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblSS" runat="server" Text='<%# Bind("OnHand") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Max Point">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblMaxPoint" runat="server" Text='<%# Bind("MaxPoint") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Order Point">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblOrderPoint" runat="server" Text='<%# Bind("OrderPoint") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Sea">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblSea" runat="server" Text='<%# Bind("SeaQty") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Air">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblAir" runat="server" Text='<%# Bind("AirQty") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Warning Point">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblWarningPoint" runat="server" Text='<%# Bind("WarningPoint") %>'
                                            BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Open PO ">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblOpenPO" runat="server" Text='<%# Bind("OpenPO") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Open SO ">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblOpenSO" runat="server" Text='<%# Bind("OpenSO") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Plan Order Qty">
                                    <ItemStyle HorizontalAlign="Center" Width="50px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblOrderQty" runat="server" Text='<%# Bind("OrderQty") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle BackColor="#6095C9" Font-Bold="true" ForeColor="#ffffff" Font-Overline="False"
                                Height="27px" VerticalAlign="Middle" />
                            <EmptyDataTemplate>
                                <table class="GridInner" style="width: 100%; border-color: White;" border="1" rules="all"
                                    cellspacing="2" cellpadding="2">
                                    <tr valign="middle" style="height: 27px; color: white; text-decoration: none; background-color: rgb(96, 149, 201);">
                                        <th>
                                            <span>#</span>
                                        </th>
                                        <th>
                                            <span>Parts No</span>
                                        </th>
                                        <th>
                                            <span>Parts Name</span>
                                        </th>
                                        <th>
                                            <span>Vendor</span>
                                        </th>
                                        <th>
                                            <span>Model</span>
                                        </th>
                                        <th>
                                            <span>ABC</span>
                                        </th>
                                        <th>
                                            <span>Class</span>
                                        </th>
                                        <th>
                                            <span>Number. of items</span>
                                        </th>
                                        <th>
                                            <span>Number of line items</span>
                                        </th>
                                        <th>
                                            <span>Cumulated items</span>
                                        </th>
                                        <th>
                                            <span>Target Fill Rate</span>
                                        </th>
                                    </tr>
                                    <tr>
                                        <td colspan="11">
                                            <span>No Data</span>
                                        </td>
                                    </tr>
                                </table>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </div>
                    <hr width="100%" />
                </div>
                <table width="100%" border="0">
                    <tr>
                        <td valign="top" style="width: 300px;">
                            <table>
                                <tr>
                                    <td>
                                        <strong>Remarks:</strong>
                                    </td>
                                    <td>
                                        <asp:TextBox runat="server" ID="txtRemarks" Height="71px" TextMode="MultiLine" Width="310px"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div style="margin-left: 5px; width: 99%;">
                                <hr />
                            </div>
                            <table style="width: 100%">
                                <tr>
                                    <td style="width: 220px;">
                                        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" Width="80px" />
                                    </td>
                                    <td>
                                        <asp:Label ID="lblError" runat="server" Visible="False" Font-Bold="True" ForeColor="Red"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
